app.filter('warsName', function() {
	return function(x) {
		if(x == "DIANBIAO") {
			return '电表';
		} else if(x == "MENSUO") {
			return '门锁';
		}

	};
});
//门锁电表样式中间留空
app.filter('style', function() {
	return function(x) {
		if(x == "DIANBIAO") {
			return 'margin-right:20px';
		} else if(x == "MENSUO") {
			return 'margin-right:20px';
		}

	};
});
app.filter('paymod', function() {
	return function(x) {
		if(x == "1") {
			return '预付费模式';
		} else if(x == "0") {
			return '后付费模式';
		}

	};
});
//门锁在线离线状态
app.filter('hardwarestatus_1_1', function() {
	return function(x) {
		if(x == "on") {
			return '在线';
		} else if(x == "off") {
			return '离线';
		}

	};
});

app.filter('hardwarestatus_1', function() {
	return function(x) {
		if(x == 'on') {
			return '在线';
		} else if(x == 'off') {
			return '离线';
		}

	};
});
app.filter('hardwarestatus_2', function() {
	return function(x) {
		if(x == 'on') {
			return '通电';
		} else if(x == 'off') {
			return '断电';
		}

	};
});
//按钮状态相反
app.filter('hardwarestatus_2_1', function() {
	return function(x) {
		if(x == 'on') {
			return '断电';
		} else if(x == 'off') {
			return '通电';
		}

	};
});
app.filter('hardwarestatus_3', function() {
	return function(x, data) {
		if(data == "on") {
			if(x >= 20) {
				return '正常';
			} else if(x < 20) {
				return '低电量';
			}
		} else {
			return '离线状态不可查';
		}

	};
});

//分割字符串
app.filter('split_0', function() {
	return function(x) {
		var strs = new Array(); //定义一数组 
		var strs = x.split("_"); //字符分割 
		return strs[0];
	};
});
app.filter('split_1', function() {
	return function(x) {

		var strs = new Array(); //定义一数组 
		var strs = x.split("_"); //字符分割 
		return strs[1];

	};
});

//过滤省市区id
app.filter('proName', function() {
	return function(id, data) {
		var strs;
		angular.forEach(data, function(i) {
			if(i.pro_id == id) {
				strs = i.name;
			}
		});
		return strs;
	}
});
app.filter('cityName', function() {
	return function(id, data) {
		var strs;
		angular.forEach(data, function(i) {
			if(i.city_id == id) {
				strs = i.name;
			}
		});
		return strs;
	}
});
app.filter('disName', function() {
	return function(id, data) {
		var strs;
		angular.forEach(data, function(i) {
			if(i.dis_id == id) {
				strs = i.name;
			}
		});
		return strs;
	}
});

//开门方式
//开门类型 机械钥匙开门0，刷卡开门1，手机开门3，密码开门6，动态密码7
//手机开门 1，密码开门 2 ，第三方平台开门 3 ,一次性密码开门  4, 动态密码  5, 机械钥匙开门   6 ，刷卡开门  7  ,  其他  8
app.filter('openType', function() {
	return function(x) {
		if(x == 1) {
			return '手机开门';
		} else if(x == 2) {
			return '密码开门';
		} else if(x == 3) {
			return '第三方平台开门';
		} else if(x == 4) {
			return '一次性密码开门';
		} else if(x == 5) {
			return '动态密码';
		} else if(x == 6) {
			return '机械钥匙开门';
		}else if(x == 7) {
			return '刷卡开门';
		}else if(x == 8) {
			return '其它';
		}

	}
});

//系统日志备注过滤
app.filter('oRemark', function() {
	return function(str, pro, cty, dis) {
		var oArry = str.split('_');
		var p, c, d;
		if(oArry.length > 1) {
			angular.forEach(pro, function(i) {
				if(i.pro_id == oArry[1]) {
					p = i.name;
				}
			});
			angular.forEach(cty, function(i) {
				if(i.city_id == oArry[2]) {
					c = i.name;
				}
			});
			angular.forEach(dis, function(i) {
				if(i.dis_id == oArry[3]) {
					d = i.name;
				}
			});
			var oStr = oArry[0] + p + c + d + oArry[4]
			return oStr;

		} else {
			return oArry[0];
		}

	}
});
//----------------------------新增过滤器---------------------------------//
//联网历史在线离线状态
app.filter('onlineStatus', function() {
	return function(x) {
		if(x == "off") {
			return '离线';
		} else if(x == "on") {
			return '在线';
		}

	};
});
//用户权限控制过滤
app.filter('userAcc', function() {
	return function(data, ele) {
		var arry = [];
		for(var i = 0; i < data.length; i++) {
			if(data[i].access == ele || data[i].role == ele || data[i].handle == ele) {
				arry.push(data[i])
			}

		}
		return arry;
	}
});
//过滤成两位小数展示
app.filter('mathFloor', function() {
	return function(x) {
		
		return Math.floor( x*100) / 100;

	};
});
//0unit 0floorNo list
app.filter('clearZero', function() {
	return function(x) {
		if (x == 0) {
			return '';
		} else{
			return x;
		}

	};
});
//0floorNo card
app.filter('floorZero', function() {
	return function(x) {
		if (x == 0) {
			return '';
		} else{
			return x+'栋';
		}

	};
});
//0unit list
app.filter('unitZero', function() {
	return function(x) {
		if (x == 0) {
			return '';
		} else{
			return x+'单元';
		}

	};
});